package LRU;

import java.util.Map;

/**
 * @author K
 * @date 2021/7/5 上午10:34
 */
public class Run {
    public static  void main(String[] args) {

        LFU<Integer, String> LFUCache = new LFU<>(5);
        LFUCache.put(1, "A");
        LFUCache.put(2, "B");
        LFUCache.put(3, "C");
        LFUCache.put(4, "D");
        LFUCache.put(5, "E");
        LFUCache.put(6, "F");
        LFUCache.get(2);
        LFUCache.get(2);
        LFUCache.get(3);
        LFUCache.get(6);
        //重新put节点3
        LFUCache.put(3, "C");

        // 顺序应该是:C->B->F->E->D
        final Map<Integer, Node> caches = (Map<Integer, Node>) LFUCache.getCaches();
        for (Map.Entry<Integer, Node> nodeEntry : caches.entrySet()) {
            System.out.println(nodeEntry);
        }

        // lfuSortOptimize
        LFUSortOptimize<Integer, String> lfuSortOptimize = new LFUSortOptimize<>(5);

        lfuSortOptimize.put(1, "A");
        lfuSortOptimize.put(2, "B");
        lfuSortOptimize.put(3, "C");
        lfuSortOptimize.put(4, "D");
        lfuSortOptimize.put(5, "E");
        lfuSortOptimize.put(6, "F");
        lfuSortOptimize.get(2);
        lfuSortOptimize.get(2);
        lfuSortOptimize.get(3);
        lfuSortOptimize.get(6);
        //重新put节点3
        lfuSortOptimize.put(3, "C");

        // 顺序应该是:C->B->F->E->D
        final Map<Integer, Node> lfuSortOptimizeCaches = (Map<Integer, Node>) lfuSortOptimize.getCaches();
        for (Map.Entry<Integer, Node> nodeEntry : lfuSortOptimizeCaches.entrySet()) {
            System.out.println(nodeEntry);
        }
    }
}
